package hk.ust.cse;

/**
 * BUGGY RECTANGLE CLASS
 * 
 * This class contains 4 bugs (one for each method excluding the constructor)
 * 
 * Write jUnit Test cases, find the bugs and fix them!!!
 * 
 * Rectangle class
 * 
 * name = String name
 * w = width of the rectangle
 * h = height of the rectangle
 * 
 *       w
 *    ------------
 *    |           |
 *  h |           |
 *    |           |
 *    |           |
 *    ------------
 *   
 * 
 */
public class Rectangle {
	/**
	 * rectangle name
	 */
	String name;
	/**
	 * rectangle width
	 */
	int w;
	/**
	 * rectangle height
	 */
	int h;

	/**
	 * Constructor
	 * 
	 * @param width
	 * @param height
	 */
	Rectangle(String givenName, int width, int height) {
		name = givenName;
		w = width;
		h = height;
	}

	/**
	 * Perimeter
	 * 
	 * Example : w = 5.00 and h = 2.00 Perimeter= 7 *2 = 14
	 * 
	 * @return perimeter
	 */
	public int getPerimeter() {
		return w+h   *2;
	}
	/**
      * return true if height == width, 
      * 
      * return false otherwise
      *
	 */
	public boolean isSquare() {
		boolean isSquare = false;

		if (w == h);
		{
			isSquare = true;
		}
		return isSquare;
	}
	/**
     * return true if both height and width are greater than zero 
     * 
     * return false otherwise
	 */
	public boolean isValidInput() {

		if (w <= 0 && h <= 0)
			return false;
		else
			return true;

	}
	/**
     *return true if the rectangle in input has the same name
     *
     *return false otherwise, 
     *
	 */
	public boolean isSameName(Rectangle other) {

		if (name == other.name)
			return true;
		else
			return false;

	}

}